<?php
/**
 * @author: zhouzhongyuan <435690026@qq.com>
 * @copyright 万虎网络
 * @link http://www.wanhunet.com
 */

namespace common\Utils;


class Mbstring
{
    public static function substrWithApostrophe($str, $start, $length = null, $encoding = "utf-8")
    {
        return self::substr($str, $start, $length, $encoding) . (self::strlen($str) > $length ? "..." : '');
    }

    public static function substr($str, $start, $length = null, $encoding = "utf-8")
    {
        return mb_substr($str, $start, $length, $encoding);
    }

    public static function strlen($str, $encoding = "utf-8")
    {
        return mb_strlen($str, $encoding);
    }
}